package com.xuerhua.yxt.controller.sys.repair;

import java.util.Arrays;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.xuerhua.yxt.common.RspResult;
import com.xuerhua.yxt.common.enums.Status;
import com.xuerhua.yxt.controller.BaseController;
import com.xuerhua.yxt.model.Grid;
import com.xuerhua.yxt.model.RepairBuilding;
import com.xuerhua.yxt.service.IOnlineRepairService;

@RequestMapping("sys/repair/building")
@Controller
public class SysRepairBuildingConfController extends BaseController {
	
	@Autowired
	private IOnlineRepairService onlineRepairService;
	
	@RequestMapping(value={"","/"})
	public String Index() {
		return "sys/repair/building";
	}
	
	@RequestMapping("pageQuery")
	@ResponseBody Object pageQuery(Integer schoolId){
		try {
			List<RepairBuilding> list = onlineRepairService.selectRepairBuildingList(schoolId);;
			Grid grid = new Grid();
			grid.setRows(list);
			grid.setTotal(list.size());
			return grid;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	
	@RequestMapping("addUpdate")
	@ResponseBody Object addUpdate(RepairBuilding record) {
		try {
			onlineRepairService.addAndUpdateRepairBuilding(record);
			return new RspResult(Status.SUCCESS);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return new RspResult(Status.FAIL);
	}
	
	@RequestMapping("del")
	@ResponseBody Object del(String delIds) {
		try {
			onlineRepairService.delRepairBuilding(Arrays.asList(delIds.split(",")));
			return new RspResult(Status.SUCCESS);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return new RspResult(Status.FAIL);
	}
	
}
